package com.test.ql;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;


/**
 * BBS主题
 * @author agnteeq
 *
 */
@Entity
@NamedQueries(
		{
			@NamedQuery(name="topic.selectById",query="from Topic t where t.id = :id")
		}
		)
public class Topic {

	private int id;
	private String title;
	private Category category;
	private Date createDate;
	private Set<Msg> msg = new HashSet<Msg>();
	
	@OneToMany(mappedBy="topic")
	public Set<Msg> getMsg() {
		return msg;
	}
	public void setMsg(Set<Msg> msg) {
		this.msg = msg;
	}
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="category_id")
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	
	
	
	
}
